import { Entity, UpdateDate, CreateDate, Salt, Username, PrimaryUuid, Unique, Realname, Role, Email, Mobile, Avatar, Password, Boolean, SysUGroupId, SysUserId, CreateUserId, Uuid, Link, SimpleJson, DateTime, Ip, Digdit } from '@sker/core'
/**
 * 后台用户
 */
@Entity({
    name: 'sys_user'
})
@Unique('UK_SYS_USER_USERNAME', ['username'])
@Unique('UK_SYS_USER_MOBILE', ['mobile'])
@Unique('UK_SYS_USER_EMAIL', ['email'])
export class SysUser {
    static title: string = `用户`;
    static resource: string = `sys_user`;

    @PrimaryUuid({ comment: '用户编号', primaryKeyConstraintName: "PK_SYS_USER_ID" })
    uid!: string;

    @Uuid({ comment: '代理ID', nullable: true })
    aid: string;

    @Boolean({ comment: '是否管理员', default: false })
    is_admin: boolean;

    @Username({
        type: 'varchar',
        length: 50,
        comment: '用户名',
        nullable: true
    })
    username!: string;

    @Realname({
        comment: '真实姓名',
        default: ''
    })
    realname!: string;

    @Role({
        comment: '角色',
        default: ''
    })
    role!: string;

    @Email({
        comment: '邮箱',
        nullable: true
    })
    email!: string;

    @Mobile({
        comment: '手机号',
        nullable: true
    })
    mobile!: string;

    @Avatar({
        comment: '用户头像',
        default: ''
    })
    avatar!: string;

    @Password({
        type: 'varchar',
        length: 255,
        comment: '密码',
        default: ''
    })
    password!: string;

    @Boolean({
        comment: '用户状态',
        default: true
    })
    status!: boolean;

    @Boolean({ default: false })
    online: boolean;

    @Salt({
        type: 'varchar',
        length: 20,
        comment: '加密盐',
        default: ''
    })
    salt!: string;

    @SysUGroupId({ comment: '用户组', nullable: true })
    group_id!: string;

    @CreateUserId()
    create_uid!: string;

    @Uuid()
    owner_uid?: string;

    @Ip({ nullable: true })
    joinip: string;

    @DateTime({ nullable: true })
    joindate: Date;

    @DateTime({ nullable: true })
    lastvisit: Date;

    @Uuid()
    member_id: string;

    @Link({ default: '/fj/core/web/company' })
    welcome_link: string;

    @SimpleJson({ nullable: true })
    notice_setting: any;

    @Boolean({ default: false })
    is_bind: boolean;

    @Digdit({ default: 0 })
    login_count: number;

    @CreateDate({
        comment: '创建日期'
    })
    create_date!: Date;

    @UpdateDate({
        comment: '更新日期'
    })
    update_date!: Date;
}